<%@page import="application.ImageBean"%>
<%@page import="controleur.ConstantesWeb"%>
<%@page import="java.io.OutputStream"%>
<%@page import="application.Facade"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%
    Facade f = new Facade();
    ImageBean i;

    if (request.getParameter(ConstantesWeb.VALEUR_IMAGE_ID) != null) {
        i = f.getImage(request.getParameter(ConstantesWeb.VALEUR_IMAGE_ID));
    } else {
        i = (ImageBean) request.getAttribute(ConstantesWeb.VALEUR_IMAGE);
    }

    if (i != null) {
        response.setContentType("image");
        OutputStream o = response.getOutputStream();
        o.write(i.getImage().getBytes(1, (int) i.getImage().length()));
        o.flush();
        o.close();
    } else {
        out.print("<h1 align=\"center\">L'identifiant de l'image est invalide.</h1>");
    }
%>
